<template>
  <div id="chart" :style="{height:height,width:width}" />
</template>

<script>
import * as echarts from 'echarts'
import resize from '../../components/Charts/mixins/resize'
import loadApi from '@/api/img';
export default {
  name: 'lineShow',
  mixins: [resize],
  props: {
    width: {
      type: String,
      default: '100%'
    },
    height: {
      type: String,
      default: '1000%'
    }
  },
  data(){
    return {

    }
  },
  mounted() {
    this.setChart()
  },
  methods:{
    async setChart() {
      // 基于准备好的dom，初始化echarts实例
      this.chart = echarts.init(document.getElementById('chart'))
      var xAxisData=[]
      var seriesData=[]
      let res = await loadApi.listAll()
      for (var i=0;i<res.data.length;i++) {
        xAxisData.push(res.data[i].entryname+res.data[i].projectname)
        seriesData.push(res.data[i].quantities)
        console.log(xAxisData)
      }

      // 指定图表的配置项和数据
      var option = {
        xAxis: {
          type: 'category',
          data: xAxisData
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data: seriesData,
            type: 'line',
          }
        ]
      };
      this.chart.setOption(option)
    }
  },
}
</script>

<style scoped>

</style>
